package com.concandthreads;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by nkrivko on 05.12.2014.
 */
public class BarrierHolder {

    final static CyclicBarrier BARRIER =new CyclicBarrier(1,new Runnable() {
        @Override
        public void run() {
            System.out.println("runnable hit");
        }
    });

    public void doIt(){
        ReentrantLock reentrantLock = new ReentrantLock();
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    BARRIER.await();
                    System.out.println("await");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } catch (BrokenBarrierException e) {
                    e.printStackTrace();
                }
            }
        }).start();


    }


}
